package com.accp.controller;

import java.sql.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import com.accp.entity.Comments;
import com.accp.entity.DataResult;
import com.accp.service.CommentsService;



@RestController
public class CommentController {
		@Autowired
		CommentsService cs;
		
		@PostMapping("/add")
		public DataResult addComment(Comments comments){
			comments.setCommentDate(new Date(System.currentTimeMillis()));
			cs.addComments(comments);
			return DataResult.getSuccessResult(comments);
		}
		
		@GetMapping("/get")
		public DataResult get(int hotEventsId){
			List<Comments> list = cs.findAll(hotEventsId);
			return DataResult.getSuccessResult(list);
		}
}
